package com.sicheng.蓝桥.国赛准备;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Objects;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/10 23:40
 */
public class 切割 {
    static class Line {
        int x1, y1, x2, y2;

        void set() {
            int p = p(a, b, c);
            if (p != 0) {
                a = a / p;
                b = b / p;
                c = c / p;
            }

        }

        int a;
        int b;
        int c;

        int getA() {
            return x2 - x1;
        }

        int getB() {
            return y2 - y1;
        }

        int getC() {
            return y1 * x2 - x1 * y2;
        }

        static int p(int a, int b, int c) {
            return gcd(gcd(a, b), c);
        }

        static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        public Line(int x1, int y1, int x2, int y2) {
            this.x1 = x1;
            this.y1 = y1;
            this.x2 = x2;
            this.y2 = y2;
            a = getA();
            b = getB();
            c = getC();
            set();
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Line line = (Line) o;
            return a == line.a && b == line.b && c == line.c;
        }

        @Override
        public int hashCode() {
            return Objects.hash(a, b, c);
        }
    }

    static class P {
        int x;
        int y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        int n = 4;
        ArrayList<P> ps = new ArrayList<>();
        HashSet<Line> lines = new HashSet<>();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ps.add(new P(i, j));
            }
        }

        for (int i = 0; i < ps.size(); i++) {
            for (int j = i + 1; j < ps.size(); j++) {
                P p1 = ps.get(i);
                P p2 = ps.get(j);
                Line line = new Line(p1.x, p1.y, p2.x, p2.y);
                lines.add(line);
            }
        }

        System.out.println(lines.size());
    }

}
